// 城市选择器 
function picker() {
    new Picker({
        title: "请滑动屏幕选择", //标题(可选)
        defaultValue: `{$provincename["pname"]} {$cityname}`, //默认值-多个以空格分开（可选）
        data: cityData, //数据(必传)
        type: 2,
        keys: {
            id: "code",
            value: "name",
            childData: "level", //最多3级联动
        }, //数组内的键名称(必传，id、text、data)
        callBack: function (val) {
            //回调函数（val为选择的值）
            let city = val.split(" ");
            let qu = "";
            if (city[1] != "") {
                $("#sheng").val(city[0]);
                $("#shi").val(city[1]);
                let citycode = shiData[city[0]]["citylist"][city[1]]["code"];
                if (citycode == "sz" || citycode == "hk") {
                    window.location.href =
                        "http://m.bendibao.com/news/zhonggaokaoshengfuli/";
                } else if (citycode == "am") {
                    window.location.href =
                        "http://m.zh.bendibao.com/news/zhonggaokaoshengfuli/";
                } else {
                    window.location.href =
                        "http://m." +
                        citycode +
                        ".bendibao.com/news/zhonggaokaoshengfuli/";
                }
            }
        },
    });
}

$(document).ready(function () {
    // if($(".strategy-wrap .fuli-wrap").find(".strategy-inner").length==0){
    //     $(".mianfei-wrap").show();
    // }else if($(".strategy-wrap .mianfei-wrap").find(".strategy-inner").length==0){
    //     $(".other-wrap").show();
    // }
    let epidemicLength=$(".epidemic-msg-wrap").length;
    for(i=0;i<epidemicLength;i++){
        let checkAll=$(".epidemic-msg-wrap").eq(i).find(".check-all");
        if ($(".epidemic-msg-wrap").eq(i).find(".msg-line:hidden").length == 0) {
            checkAll.hide();
        }
    }
    // let checkAll=$(".epidemic-msg-wrap .check-all");
    // console.log("checkall:",$(".epidemic-msg-wrap .check-all"));
    // console.log("checkallparen:",checkAll.parent(".epidemic-msg-wrap"));   
    // let paren= checkAll.parent(".epidemic-msg-wrap");
    // console.log("length:",paren.find(".msg-line:hidden").length);    
    // if (paren.find(".msg-line:hidden").length == 0) {
    //     checkAll.hide();
    // }
    

    $(".strategy-wrap").find(".strategy-container").eq(0).show();
    // 展示考生福利下的第一个outer
    $(".fuli-wrap").find(".outer").eq(0).show();


    $(".index-wrap").find(".margin-wrap").eq(0).addClass("top-style");
    $(".travel-tools-wrap").find(".tools-container").eq(0).show();
    $(".epidemic").find(".epidemic-msg-wrap").eq(0).show();

    $(".strategy-nav .strategy-nav-li:first-child").addClass("nav-style");
    $(".tools-nav .tools-nav-li:first-child").addClass("tools-style");
    $(".epidemic-nav .epidemic-li:first-child").addClass("information-style");
    $(".play-btn .play:first-child").addClass("play-style");

    $(".lastnews-wrap .news-line:nth-of-type(3)").nextAll().css("display", "none");
    let newsLength = $(".news-line").length;
    if (newsLength <= 3) {
        $(".lastnews-wrap .check-more").css("display", "none");
        $(".lastnews-wrap .news-line:last-of-type").addClass("news-style");
    }
    $(".epidemic-nav .info-li").find(".more-icon").addClass("icon-arrow-down");

    $(".fuli-wrap .more").find(".down").addClass("icon-arrow-down");

    $(".detail-container .strategy-inner:first-of-type").find(".switch-fold").addClass("icon-arrowup");
    $(".detail-container .strategy-inner:first-of-type").siblings().find(".switch-fold").addClass("icon-arrow-down");
    $(".detail-container .strategy-inner:first-of-type").siblings().find(".activity-title").addClass("acttitle-style");
    $(".detail-container .strategy-inner:first-of-type").siblings().find(".activity").addClass("activity-style");
    $(".detail-container .strategy-inner:first-of-type").siblings().addClass("detail-style");
    $(".detail-container .strategy-inner:first-of-type").siblings().find(".time-wrap").hide();
    $(".detail-container .strategy-inner:first-of-type").siblings().find(".location-wrap").hide();
    $(".detail-container .strategy-inner:first-of-type").siblings().find(".enter").hide();
    $(".detail-container .strategy-inner:first-of-type").siblings().find(".play-btn").hide();
    $(".detail-container .strategy-inner:first-of-type").siblings().find(".ticket-wrap").hide();
    $(".detail-container .strategy-inner:first-of-type").siblings().find(".obj-wrap").hide();

    $(".fuli-wrap .mianfei-outer .strategy-inner:nth-of-type(6)").nextAll().css("display", "none");
    $(".fuli-wrap .youhui-outer .strategy-inner:nth-of-type(6)").nextAll().css("display", "none");

    $(".mianfei-wrap .strategy-inner:nth-of-type(6)").nextAll().css("display", "none");
    $(".qita-wrap .strategy-inner:nth-of-type(6)").nextAll().css("display", "none");
    let innerLength1 = $(".fuli-wrap .mianfei-outer .strategy-inner").length;
    let innerLength12 = $(".fuli-wrap .youhui-outer .strategy-inner").length;
    let innerLength2 = $(".mianfei-wrap .strategy-inner").length;
    let innerLength3 = $(".qita-wrap .strategy-inner").length;
    if (innerLength1 <= 6) {
        $(".fuli-wrap .mianfei-outer .more").css("display", "none");
    }
    if (innerLength12 <= 6) {
        $(".fuli-wrap .youhui-outer .more").css("display", "none");
    }
    if (innerLength2 <= 6) {
        $(".mianfei-wrap .more").css("display", "none");
    }
    if (innerLength3 <= 6) {
        $(".qita-wrap .more").css("display", "none");
    }

    $(".epidemic-msg-wrap .msg-line:nth-of-type(5)").nextAll().css("display", "none");
    if ($(".epidemic-msg-wrap .msg-line").length <= 5) {
        $(".epidemic .check-all").css("display", "none");
    }




})

// 最新消息查看更多:3条3条展示
// $(".lastnews-wrap .check-more").on("click", function () {
//     $(".lastnews-wrap .news-line:nth-of-type(3)").nextAll().toggle();
// })
var numnewsline = 3;
    $(".lastnews-wrap .check-more").click(function () {
        let paren= $(this).parent(".lastnews-wrap");
        paren.find(`.news-line:lt(${3+numnewsline})`).show();
        numnewsline += 3;
        if (paren.find(".news-line:hidden").length == 0) {
            $(this).hide();
        }
        // $(".epidemic-msg-wrap").find(`.msg-line:lt(${5+num})`).show();
        // num += 5;
        // if ($(".epidemic-msg-wrap").find(".msg-line:hidden").length == 0) {
        //     $(this).hide();
        // }
    });

// 常用出行工具导航切换
$(".tools-nav-li").on("click", function () {
    const index = $(this).index();
    $(this).addClass("tools-style");
    $(this).siblings().removeClass("tools-style");
    $(".tools-container").eq(index).css("display", "block").siblings().css("display", "none");
})
// 游玩攻略导航
$(".strategy-nav-li").on("click", function () {
    const index = $(this).index();
    $(this).addClass("nav-style");
    $(this).siblings().removeClass("nav-style");
    $(".strategy-container").eq(index).css("display", "block").siblings().css("display", "none");
})
// play免费游玩优惠游玩
$(".play").on("click", function () {
    const index = $(this).index();
    $(this).addClass("play-style");
    $(this).siblings().removeClass("play-style");

    let playparent = $(this).parents(".fuli-wrap");
    playparent.find(".outer").eq(index).css("display", "block").siblings().css("display", "none");
    // $(".play-container").eq(index).css("display","block").siblings().css("display","none");
})
// 游玩景点的展开与收起
$(".detail-container .switch-fold").on("click", function () {
    $(this).toggleClass("icon-arrowup icon-arrow-down");
    $(this).parent().toggleClass("  acttitle-style");
    $(this).parents(".activity").toggleClass("  activity-style");
    $(this).parents(".strategy-inner").toggleClass("  detail-style");
    let myParent = $(this).parents(".strategy-inner");
    myParent.find(".play-btn").toggle();
    myParent.find(".time-wrap").toggle();
    myParent.find(".ticket-wrap").toggle();
    myParent.find(".obj-wrap").toggle();
    myParent.find(".location-wrap").toggle();
    myParent.find(".enter").toggle();
})

// 攻略查看更多
$(".fuli-wrap .more").on("click", function () {
    // 下拉框图标切换
    $(this).find(".down").toggleClass("icon-arrow-down icon-arrow-down");
    const moreparent = $(this).parent(".outer");

    moreparent.find(".strategy-inner:nth-of-type(6)").nextAll().show();
    // $(".fuli-wrap .outer .strategy-inner:nth-of-type(6)").nextAll().show();

    if (moreparent.find(".strategy-inner:hidden").length == 0) {
        $(this).hide();
    }

})
$(".mianfei-wrap .more").on("click", function () {
    $(".mianfei-wrap .strategy-inner:nth-of-type(6)").nextAll().show();
    const moreparent = $(this).parent(".mianfei-wrap");
    if (moreparent.find(".strategy-inner:hidden").length == 0) {
        $(this).hide();
    }
})
$(".qita-wrap .more").on("click", function () {
    $(".qita-wrap .strategy-inner:nth-of-type(6)").nextAll().show();
    const moreparent = $(this).parent(".qita-wrap");
    if (moreparent.find(".strategy-inner:hidden").length == 0) {
        $(this).hide();
    }
})

// 资讯导航切换
$(".epidemic-li").on("click", function () {
    $(this).addClass("information-style");
    $(this).siblings().removeClass("information-style");

    const index = $(this).index();
    const eplength = $(".epidemic-li").length;
    if (index < eplength - 1) {
        $(".epidemic-msg-wrap").eq(index).css("display", "block").siblings().css("display", "none");
        $(".epidemic-nav .info-li .info-more").hide();
    }

})
// 资讯查看全部资讯
// $(".epidemic-msg-wrap .check-all").on("click", function () {
//     $(".epidemic-msg-wrap .msg-line:nth-of-type(5)").nextAll().toggle();
// })

// 五条五条展示
var num = 5;
    $(".epidemic-msg-wrap .check-all").click(function () {
        let paren= $(this).parent(".epidemic-msg-wrap");
        paren.find(`.msg-line:lt(${5+num})`).show();
        num += 5;
        if (paren.find(".msg-line:hidden").length == 0) {
            $(this).hide();
        }
        // $(".epidemic-msg-wrap").find(`.msg-line:lt(${5+num})`).show();
        // num += 5;
        // if ($(".epidemic-msg-wrap").find(".msg-line:hidden").length == 0) {
        //     $(this).hide();
        // }
    });

// 资讯下的更多弹框
$(".epidemic-nav .info-li").on("click", function () {
    $(this).find(".more-icon").toggleClass("icon-arrow-down icon-arrowup ");
    $(this).find(".info-more").toggle();
    $(this).find(".info-more").toggleClass("  more-style");
})

// 资讯导航栏下的更多导航栏
$(".info-more .info-line").on("click", function () {
    // 前面一个的index
    const length = $(".epidemic-nav .epidemic-li").length - 1;
    const index = $(this).index();

    const final = length + index;

    $(".epidemic-msg-wrap").eq(final).css("display", "block").siblings().css("display", "none");

})